#ifndef Inspector_First
#define Inspector_First
#ifdef __GNUG__
#pragma interface
#endif

#include "CollView.h"
#include "EtPeTool.h"

class PeClassListView;
class PeFindInspReferences;
class PeObjectView;
class OrdCollection;
class Ref;
class Class;
class TextField;

//---- PeInspector -------------------------------------------------------------

class PeInspector: public EtPeTool {
public:
	MetaDef(PeInspector);
	PeInspector(Manager *m);
	~PeInspector();

	void Init(Object *op);
	void LoadObjectsOfClass(Class*, bool members);
	void Member(int mode, const char *name, int offset, int size= 0);
	void References(Object*);
	void Reset();
	void ResetReferences();
	void FoundReference(Object *op, const char *name, int index= -1);
	void ResetObjects();
	void FreedMemory(void *addr, void *end);
	void DoInspect(Object *);

	void MoveTo(int pos);
	void Push(Ref *r);
	void ShowReference(Ref *);
	void ShowClass(Class *cl);
	void ShowObject(Object *op);
	void SelectAndRevealItem(CollectionView *cv, int at);

	//---- menus
	void Control(int id, int, void *v);
	void DoSetupMenu(Menu *menu);
	Command *DoMenuCommand(int cmd);
	void UpdateButtons();

	//---- commands
	void ShowAllInstances();

	friend void InspectorFreeHook(void*, void*, size_t);
	void RemoveDeletedRef(int i, Ref *r);

	static void Spawn(Manager *m, Ref *ref, bool block);
	static void ShowObject(Manager *m, Object *op, bool block);

protected:
	VObject *DoMakeContent();
	MenuBar *DoMakeMenuBar();

private:
	static PeInspector *inspector;
	static int inspcnt;
	static OrdCollection *allInspectors;

	CollectionView *objects, *references;
	PeClassListView *classes;
	OrdCollection *classItems;
	SeqCollection *objectItems, *referenceItems;
	TextField *refTitle, *objTitle;
	VObject *start, *left, *right, *end;
	Object *currentOp;
	PeFindInspReferences *findReferences;
	PeObjectView *objView;
	OrdCollection *path;
	int position;
};

#endif
